# import sys
# file = sys.stdout
# file.write("Hello")
# print("world")
#
#
# file = open('test.txt', 'r')
# # print(file.read())
# print(file.read(3))
# file.close()
# #无需写close
with open('test.txt', 'r',encoding='utf-8') as file2:
    # print(file2.read())
    # print(file2.readline())
    list2 = file2.readlines()
    print(list2)

str = "day day up"
with open('test.txt', 'w',encoding='utf-8') as file3:
    file3.writelines(str)

list3 = ['hello\n', 'world\n', 'python\n']
with open('test.txt', 'a',encoding='utf-8') as file4:
    file4.writelines(list3)


file = open('test.txt','rb')
print(file.read(1))
print(file.read(1))
print(file.tell())
file.seek(2,1)